package com.clkj.cldisabledmanclient.app;

import android.app.Application;
import android.content.Context;
import android.graphics.Typeface;
import android.support.multidex.MultiDex;

import com.clkj.cldisabledmanclient.BuildConfig;
import com.clkj.cldisabledmanclient.http.HttpConfig;
import com.clkj.cldisabledmanclient.http.HttpService;
import com.clkj.cldisabledmanclient.util.LogUtil;

/**
 * Created by clboys on 2019/5/8.
 */

public class CustomApplication extends Application{



    private Typeface typeface;
    private static CustomApplication mInstance;

    public static CustomApplication getInstance() {
        return mInstance;
    }

    private HttpService mHttpService;

    public Typeface getTypeface() {
        return typeface;
    }

    public void setTypeface(Typeface typeface) {
        this.typeface = typeface;
    }


    public HttpService getHttpService() {
        if (mHttpService == null) {
            mHttpService = HttpService.Factory.create(HttpConfig.URL_OF_INTERFACE_BASE);
        }
        return mHttpService;
    }


    @Override
    public void onCreate() {
        super.onCreate();


        mInstance = this;

        initLog();
        initHttpService();

        typeface = Typeface.createFromAsset(mInstance.getAssets(), "fonts/simkai.ttf");//下载的字体

    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);

        MultiDex.install(this);
    }

    private void initHttpService()
    {

        if (mHttpService == null) {
            mHttpService = HttpService.Factory.create(HttpConfig.URL_OF_INTERFACE_BASE);
        }
    }


    private void initLog() {
        LogUtil.isDebug = BuildConfig.DEBUG;
    }


}
